import 'package:bot_toast/bot_toast.dart';

enum ToastLevel {
  low(value: 2),
  normal(value: 3),
  high(value: 5),
  veryHigh(value: 10);

  const ToastLevel({required this.value});
  final int value;
}

class ToastUtil {
  /// 在插件外面再包一层；
  /// low, 设置为插件原来的默认值2s
  /// normal直接用插件的默认值，现在是3s
  /// high，设置为5s
  /// 默认参数为Normal
  static showText(
    String? text, {
    ToastLevel level = ToastLevel.normal,
  }) {
    switch (level) {
      case ToastLevel.low:
        BotToast.showText(text: text ?? "", duration: Duration(seconds: ToastLevel.low.value));
        break;
      case ToastLevel.normal:
        BotToast.showText(text: text ?? "", duration: Duration(seconds: ToastLevel.normal.value));
        break;
      case ToastLevel.high:
        BotToast.showText(text: text ?? "", duration: Duration(seconds: ToastLevel.high.value));
        break;
      case ToastLevel.veryHigh:
        BotToast.showText(text: text ?? "", duration: Duration(seconds: ToastLevel.veryHigh.value));
        break;
    }
  }

  /// 初始化Toast
  static final builder = BotToastInit();

  /// 初始化Toast
  static final observer = BotToastNavigatorObserver();
}
